package com.reggie.module.entity.dto.setmealDto;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;

import static com.reggie.common.Constant.LOGIN_SESSION;

/**
 * @Author 早睡蛋
 * @Date 2022/9/24 16:40:31
 * @Desc:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "setmeal")
public class SetmealStatusDto {

    @TableId(value = "id")
    private Long id;

    //0 停售 1 起售
    @TableId(value = "status")
    private Integer status;

    @TableId(value = "update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @TableId(value = "update_user")
    private Long updateUser;

    public SetmealStatusDto(Long id, Integer status, HttpServletRequest request){
        this.id = id;
        this.status = status;
        this.updateTime = LocalDateTime.now();
        Long empId = (Long) request.getSession().getAttribute(LOGIN_SESSION);
        this.updateUser = empId;
    }

}
